package com.fire.control.system.module.notice.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.fire.control.system.entity.NoticeDetail;
/**
 * 
 * @ClassName:  NoticeDetailRepository
 * @Description:  消息通知明细持久层
 * @author:  xiechengguang
 * @date:  2017年5月22日 下午4:26:59
 *
 */
@Repository
public interface NoticeDetailRepository extends JpaRepository<NoticeDetail, String> {
	
	@Query("from NoticeDetail d join d.notice n join d.user u where n.id = :noticeId and u.id = :userId")
	public NoticeDetail getByNoticeIdAndUserId(@Param("noticeId") String noticeId, @Param("userId") String userId); 
	
	@Transactional
	@Modifying
	@Query("update NoticeDetail d set d.sendStatus = :sendStatus where d.id = :id")
	public int setSendStatus(@Param("sendStatus") String sendStatus, @Param("id") String id);
}
